package cn.topcodes.tcsf.admin.web.controller.impl;

import cn.topcodes.tcsf.admin.commons.api.controller.query.QueryApiController;
import cn.topcodes.tcsf.admin.domain.entity.SysOperateLog;
import cn.topcodes.tcsf.admin.domain.entity.SysUser;
import cn.topcodes.tcsf.admin.domain.view.SysOperateLogVo;
import cn.topcodes.tcsf.admin.service.org.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("admin/operate-log")
public class OperateLogController extends QueryApiController<SysOperateLog,SysOperateLogVo> {

	@Autowired
	private SysUserService userService;

	@RequestMapping(value="",method=RequestMethod.GET)
	public String index() {
		return "admin/log/operate-log";
	}

	@Override
	protected SysOperateLogVo entity2Vo(SysOperateLog entity, HttpServletRequest request) {
		SysOperateLogVo vo = super.entity2Vo(entity, request);
		SysUser sysUser = userService.findOne(entity.getUserId());
		if(sysUser != null) {
			vo.setName(sysUser.getRealName());
			vo.setUsername(sysUser.getUsername());
		}
		return vo;
	}
}
